<template>
  <div class="subject">
    <span>{{ arr.f }}</span>
    <span>+</span>
    <span>{{ arr.s }}</span>
    <span>=</span>
    <input type="number" v-model="sum" />
    <button :disabled="able" @click="btn(index, sum)">提交</button>
  </div>
</template>

<script>
export default {
  props: ["arr", "index"],
  data() {
    return {
      sum: "",
      able: false,
    };
  },
  methods: {
    btn(index, sum) {
      if (this.sum === "") {
        alert("请答题");
      } else {
        this.$emit("yanzheng", index, sum);
        this.able = true;
      }
    },
  },
};
</script>

<style scoped>
.subject {
  margin: 5px;
  padding: 5px;
  font-size: 20px;
}
.subject span {
  display: inline-block;
  text-align: center;
  width: 20px;
}
.subject input {
  width: 50px;
  height: 20px;
}
</style>